
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;

public class VoitureGeneral extends JPanel {

    private JLabel lblMasse;
    private JTextField txtMasse;
    private JLabel lblKg;
    private JRadioButton inconnu;
    private JLabel lblEspace;

    public VoitureGeneral() {
        super();

        lblEspace=new JLabel("                  ");
        lblMasse = new JLabel("Masse:");
        txtMasse = new JTextField("");
        lblKg = new JLabel("Kg");
        inconnu = new JRadioButton("Inconnu");
        txtMasse.setPreferredSize(new Dimension(100, 20));

        this.add(inconnu);
        this.add(lblEspace);
        this.add(lblMasse);
        this.add(txtMasse);
        this.add(lblKg);

        inconnu.addActionListener(new GererEvenement());
    }

    public double getMasse() {
        return Double.valueOf(txtMasse.getText());
    }

    class GererEvenement implements ActionListener {

        public void actionPerformed(ActionEvent ae) {
            if (ae.getSource() == inconnu) {
                txtMasse.setEnabled(false);
            }
        }
    }
}
